import { cafReq } from "..";

// export const baseURL =
//   import.meta.env.MODE === "development"
//     ? "/mat"
//     : `${import.meta.env.VITE_REQ_URL}:30007`;
export const baseURL = `${import.meta.env.VITE_FIN_URL}`;
/**
 *下载模板
 */
export const downLoadTpl = async (params: any) => {
  console.log("12323", params);
  return await cafReq(1, { needOrigin: true, baseURL }).get(
    `/materiel/cost/maintain/v1/downTemplate`,
    params
  );
};
/**
 *上传csv文件
 */
export const uploadCsv = async (params: any) => {
  return await cafReq(2, { baseURL }).post(
    `/materiel/cost/maintain/v1/upload`,
    params
  );
};
/**
 *成本维护表的记录
 */
export const logQuery = async (params: any) => {
  return await cafReq(0, { baseURL }).post(
    `/materiel/cost/material/maintain/v1/query`,
    params
  );
};
/**
 *异常查询
 */
export const exceptionQuery = async (params: any) => {
  return await cafReq(0, { baseURL }).post(
    `/materiel/cost/material/maintain/exception/v1/query`,
    params
  );
};
/**
 *BOM成本累计
 */
export const accumulateBOM = async (params: any) => {
  return await cafReq(0, { baseURL }).post(
    `/materiel/cost/material/accumulated/v1/bom`,
    params
  );
};
/**
 *成本更新
 */
export const updateCost = async (params: any) => {
  return await cafReq(0, { baseURL }).post(
    `/materiel/cost/material/v1/update`,
    params
  );
};

/**
 *获取成本类型不含冻结
 */
export const getCostType = async (params: any) => {
  return await cafReq(0, { baseURL }).get(
    // `/materiel/cost/type/v1/query`,
    `/materiel/cost/type/v1/queryWithOutFrozenCost`,
    params
  );
};
/**
 *获取成本类型不含冻结
 */
export const getCostTypeAll = async (params: any) => {
  return await cafReq(0, { baseURL }).get(
    `/materiel/cost/type/v1/query`,
    params
  );
};
/**
 * 查询物料
 */
export const matAllQuery = async (params: any) => {
  return await cafReq(0, { baseURL }).post(
    `/materiel/cost/material/v1/queryMaterialCosts`,
    params
  );
};

/**
 * 成本类型分页查询
 */
export const queryMatCostType = async (data: any) => {
  return await cafReq(0, { baseURL }).post(
    `/materiel/cost/type/v1/page/query`,
    data
  );
};
/**
 * 新增成本类型
 */
export const addMatCostType = async (data: any) => {
  return await cafReq(0, { baseURL }).post(`/materiel/cost/type/v1/add`, data);
};
/**
 * 删除成本类型
 */
export const deleteMatCostType = async (businessId: any) => {
  return await cafReq(0, { baseURL }).delete(
    `/materiel/cost/type/v1/delete/${businessId}`
  );
};
